#ifndef SPEAKER_HPP
#define SPEAKER_HPP

#include <rclcpp/rclcpp.hpp>
#include <autopatrol_interfaces/srv/speech_text.hpp>
#include <espeak-ng/speak_lib.h>
#include <string>
#include <memory>

class Speaker : public rclcpp::Node
{
public:
    Speaker(const std::string& node_name);
    ~Speaker();

private:
    using SpeechText = autopatrol_interfaces::srv::SpeechText;
    using SpeechTextService = rclcpp::Service<SpeechText>::SharedPtr;
    
    SpeechTextService speech_service_;
    
    // espeak回调函数
    static int espeak_callback(short* wav, int numsamples, espeak_EVENT* events);
    
    // 服务回调函数
    void speak_text_callback(
        const std::shared_ptr<SpeechText::Request> request,
        const std::shared_ptr<SpeechText::Response> response);
};

#endif // SPEAKER_HPP